package com.zcp.banner;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    ArrayList<String> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        list.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488536246735&di=4f52f7e46f4141121d27b4be9f336105&imgtype=0&src=http%3A%2F%2Fpic15.nipic.com%2F20110630%2F6322714_105943746342_2.jpg");
        list.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488536271682&di=a4a1deaac5bf6f8c1978cef1bfcd31e0&imgtype=0&src=http%3A%2F%2Fpic15.nipic.com%2F20110630%2F6322714_105550198325_2.jpg");
        list.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488536307007&di=3e4c89e41b335aba103da4447aab9a20&imgtype=0&src=http%3A%2F%2Fimg02.tooopen.com%2Fimages%2F20140703%2Fsy_64539381234.jpg");
        list.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1488536338890&di=944f7b00a955380257d69eb64b9542f1&imgtype=0&src=http%3A%2F%2Fimg2.3lian.com%2F2014%2Ff2%2F8%2Fd%2F102.jpg");
        Banner banner = (Banner) findViewById(R.id.banner);
        ArrayList<String> titles = new ArrayList<>();
        titles.add("猴子");
        titles.add("熊");
        titles.add("小美女");
        titles.add("我要嫁给你");
        //String[] titles=new String[]{"猴子","熊","小美女","追"};
        //设置banner样式
        banner.setBannerStyle(BannerConfig.NUM_INDICATOR_TITLE);

        //设置图片加载器
        banner.setImageLoader(new GlideImageLoader());
        banner.setBannerTitles(titles);

        //设置图片集合
        banner.setImages(list);

        //设置自动轮播，默认为true
        banner.isAutoPlay(true);

        //设置轮播时间
        banner.setDelayTime(1500);

        //设置指示器位置（当banner模式中有指示器时）
        banner.setIndicatorGravity(BannerConfig.CENTER);

        //banner设置方法全部调用完毕时最后调用
        banner.start();
    }
}
